import { number } from 'echarts';
import { httpCreate, CommonResponse } from './http';
const http = httpCreate('/srv/activity');

export const activity = {
	// 用户-活动记录
	getActivityRecords<T>(userId: number, params: { pageNum: number; pageSize: number }) {
		return http.get<T, CommonResponse>(`/base/list/byUserId/${userId}`, {
			params,
		});
	},
	// 活动审核列表
	getActivityExamineList<T>(params: {
		pageNum: number;
		pageSize: number;
		userSearchText?: number | string;
		title?: string;
		activityId?: number;
		openType?: 0 | 1 | '0' | '1';
		publishStatus?: 0 | 1 | '0' | '1';
		payType?: 0 | 1 | '0' | '1';
		isDelete?: 0 | 1 | '0' | '1';
	}) {
		return http.get<T, CommonResponse>('/base/list/forAdmin', { params });
	},
	// 活动审核-删除活动
	deleteActivity<T>(activityId: number) {
		return http.delete<T, CommonResponse>(`/base/${activityId}`);
	},
	// 活动审核-取消发布
	cancelPublishActivity<T>(activityId: number, status: number) {
		return http.put<T, CommonResponse>(`/base/${activityId}/publish/${status}`);
	},
	// 恢复活动
	recoverActivity<T>(activityId: number) {
		return http.put<T, CommonResponse>(`/base/recover/${activityId}`);
	},
	// 操作日志
	getOperationJournalList<T>(params: {
		operatorPhone?: number;
		startTime?: number;
		endTime?: number;
		pageNum: number;
		pageSize: number;
	}) {
		return http.get<T, CommonResponse>('/logRecord/admin/all', { params });
	},
	// 数据概况
	getGlobalStatistics<T>() {
		return http.get<T, CommonResponse>('/global/statistics');
	},
	//
	// 用户折线图
	getUserEchartsData<T>(params: { startDate?: string; endDate?: string; type: number }) {
		return http.get<T, CommonResponse>('/global/statistics/userChart', {
			params,
		});
	},
	// 接待计划折线图
	getPlanEchartsData<T>(params: { startDate?: string; endDate?: string; type: number }) {
		return http.get<T, CommonResponse>('/global/statistics/activityChart', {
			params,
		});
	},
	// 活动折线图
	getActivityEchartsData<T>(params: { startDate?: string; endDate?: string; type: number }) {
		return http.get<T, CommonResponse>('/global/statistics/activityChart', {
			params,
		});
	},
	// 新增会员折线图
	// ?startDate=2022-07-01&endDate=2022-10-13&type=5
	getAddMemberEchartsData<T>(params: { startDate?: string; endDate?: string; type: number }) {
		return http.get<T, CommonResponse>('/global/statistics/memberChart', {
			params,
		});
	},
	// 活动数据-用户数据
	getActivityUserData<T>(params: { startDate: string; endDate: string }) {
		return http.get<T, CommonResponse>('/global/statistics/activity', {
			params,
		});
	},
	// ?startDate=2022-07-01&endDate=2022-10-13&type=1
	// 活动时间分布折线图
	getActivityTimeEchartsData<T>(params: { startDate: string; endDate: string; type: number }) {
		return http.get<T, CommonResponse>('/global/statistics/activityChartByStart', { params });
	},
	// 活动售票排行
	getActivitySellTicket<T>(params: { startDate: string; endDate: string }) {
		return http.get<T, CommonResponse>('/global/statistics/activity/ticketNumRank', { params });
	},
	// 活动参会排行榜
	getActivityJoinMeeting<T>(params: { startDate: string; endDate: string }) {
		return http.get<T, CommonResponse>('/global/statistics/activity/uvRank', {
			params,
		});
	},
	// 付费数据
	getPayData<T>(params: { startDate: string; endDate: string }) {
		return http.get<T, CommonResponse>('/global/statistics/payInfo', {
			params,
		});
	},
	// 付费用户新增折线图
	getPayUserCountEchartsData<T>(params: { startDate: string; endDate: string; type: number }) {
		return http.get<T, CommonResponse>('/global/statistics/payUserChart', {
			params,
		});
	},
	// 付费排行
	getPayRanking<T>(params: { startDate: string; endDate: string }) {
		return http.get<T, CommonResponse>('/global/statistics/payUserRank', {
			params,
		});
	},
	// 获取帮助中心菜单树
	getHelpTreeList<T>() {
		return http.get<T, CommonResponse>('/background-help/getHelpTree');
	},
	// 获取文档内容
	getFileContent<T>(id: string | number) {
		return http.get<T, CommonResponse>(`/background-help/getOneFile?backgroundHelpId=${id}`);
	},
	// 创建文件或文件夹
	saveFileOrFolder<T>(data: object) {
		return http.put<T, CommonResponse>('/background-help/saveFileOrFolder', data);
	},
	// 删除文档或文件夹
	deleteFileOrFolder<T>(id: string | number) {
		return http.delete<T, CommonResponse>(`/background-help/deleteFileOrFolder?backgroundHelpId=${id}`);
	},
	// 更新文档或文件夹
	updateFileOrFolder<T>(id: string | number, data: any) {
		return http.put<T, CommonResponse>(`/background-help/updateFileOrFolder/${id}`, data);
	},
	// 拖拽排序文档或文件夹
	dropFileOrFolder<T>(sourceId: string | number, targetId: string | number, dropPosition: number) {
		return http.put<T, CommonResponse>(
			`/background-help/updateFileOrFolderSort?source=${sourceId}&target=${targetId}&upOrDownOrIn=${dropPosition}`
		);
	},
	// 复制活动至案例库
	addToCaseLibrary<T>(params: { activityId: string | number }) {
		return http.post<T, CommonResponse>(`/base/addToCaseLibrary`, {}, { params });
	},
	// 获取案例的直播间列表
	getActivityCaseList<T>(
		body: { title?: string; activityId?: number | string; labelList?: Array<number> },
		params: { pageNum: number; pageSize: number }
	) {
		return http.post<T, CommonResponse>(`/base/list/superUser`, body, { params });
	},
	// 查询活动是否案例活动
	checkLibrary<T>(activityId: string | number) {
		return http.get<T, CommonResponse>(`/base/checkLibrary/${activityId}`);
	},
	// 继续复制未完成的直播间
	reCopyLibrary<T>(caseId: number) {
		return http.post<T, CommonResponse>(`/base/copyLibrary/${caseId}`);
	},
	// 获取复制任务列表
	getCopyingList<T>() {
		return http.get<T, CommonResponse>(`/base/getCopyingList`);
	},
	// 校验案例库管理员权限
	checkLibraryAdminPermission<T>() {
		return http.get<T, CommonResponse>(`/base/checkUserPermission`);
	},
	// 获取任务数量
	getCopyCount<T>() {
		return http.get<T, CommonResponse>(`/base/getCopyCount`);
	},
	// 删除案例库
	deleteCaseActivity<T>(activityId: number) {
		return http.delete<T, CommonResponse>(`/copyActivityLibrary/${activityId}`);
	},
};
